<?php
/**
* エラーチェッククラス
**/
require_once( '../system/Class_M_DAO.php' );
class Class_M_PATTERN extends Class_M_DAO {
	//protected properties begin
	/**
	 *
	 * テーブル名
	 *
	 * @access    protected
	 * @var       string
	 *
	 */
	protected $_table = "M_PATTERN";
	
	/**
	 *
	 * 主キー名
	 *
	 * @access    protected
	 * @var       string
	 *
	 */
	protected $_pkey = "pattern_cd";
	
	/**
	 *
	 * ソート順
	 *
	 * @access    protected
	 * @var       string
	 *
	 */
	 protected $_order = "pattern_cd";
	 

	 
	 protected $_cols  = array(
		"pattern_name"   => array(AOKI_VARTYPE_STR),
		"media_flg"      => array(AOKI_VARTYPE_STR),
	 );
	
	 protected $_checks  = array(
		"pattern_name"    => array( "EXIST" ),
		"media_flg"       => array( "EXIST" )
	 );
	 
	 //maxlength 
	 protected $_maxlens  = array(
		"pattern_name "   =>  30 ,
		"media_flg "      =>  1 

	 );
	
	 public function search($where ,&$page = NULL ){	
	 	
		$sql = "SELECT a.*,b.block,(select  user_name FROM M_LOGIN where id  = a.u_user) as m_user_name from {$this->_table}  a " .
				" left join   (select aa.pattern_cd,group_concat(bb.block_name  separator '\r\n')  as block from M_PATTERN_BLOCK  aa" .
				" inner join M_BLOCK bb on aa.block_cd = bb.block_cd ) b on a.pattern_cd = b.pattern_cd " ;
		return  parent::search($where ,$page ,$sql);
	}
	
}

?>